package io.renren.modules.PCguanli.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.renren.modules.PCguanli.entity.ExamineEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.PCguanli.dao.QuestionDao;
import io.renren.modules.PCguanli.entity.QuestionEntity;
import io.renren.modules.PCguanli.service.QuestionService;


@Service("questionService")
public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key=(String) params.get("key");
        LambdaQueryWrapper<QuestionEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(key), QuestionEntity::getNumber, key)
                .or().like(StringUtils.isNotEmpty(key), QuestionEntity::getContent, key)
                .or().like(StringUtils.isNotEmpty(key), QuestionEntity::getIsmust, key)
        ;
        // 构建查询条件
        IPage<QuestionEntity> page = this.page(
                new Query<QuestionEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}